HAL I2S constants migration

This section provides information about the HAL I2S constants migration.

HAL I2S error codes constants

HAL1

HAL2

#define HAL_I2S_ERROR_DMA
#define HAL_I2S_ERROR_FRE
#define HAL_I2S_ERROR_NONE
#define HAL_I2S_ERROR_OVR
#define HAL_I2S_ERROR_UDR

#define HAL_I2S_ERROR_BUSY_LINE_RX
#define HAL_I2S_ERROR_INVALID_CALLBACK
#define HAL_I2S_ERROR_NOT_SUPPORTED
#define HAL_I2S_ERROR_NO_OGT
#define HAL_I2S_ERROR_PRESCALER
#define HAL_I2S_ERROR_TIMEOUT
#define HAL_I2S_ERROR_DMA
#define HAL_I2S_ERROR_FRE
#define HAL_I2S_ERROR_NONE
#define HAL_I2S_ERROR_OVR
#define HAL_I2S_ERROR_UDR
#define HAL_I2S_ERROR_IO_LOCKED


Removed : These kinds of logical errors are reported by the direct function return.

Related concept: Revised and optimized HAL error management


HAL I2S audio frequency constants

HAL1

HAL2



#define I2S_AUDIOFREQ_192K
#define I2S_AUDIOFREQ_96K
#define I2S_AUDIOFREQ_48K
#define I2S_AUDIOFREQ_44K
#define I2S_AUDIOFREQ_32K
#define I2S_AUDIOFREQ_22K
#define I2S_AUDIOFREQ_16K
#define I2S_AUDIOFREQ_11K
#define I2S_AUDIOFREQ_8K
#define I2S_AUDIOFREQ_DEFAULT
typedef enum
{
  HAL_I2S_AUDIO_FREQ_192_KHZ,
  HAL_I2S_AUDIO_FREQ_96_KHZ,
  HAL_I2S_AUDIO_FREQ_48_KHZ,
  HAL_I2S_AUDIO_FREQ_44_KHZ,
  HAL_I2S_AUDIO_FREQ_32_KHZ,
  HAL_I2S_AUDIO_FREQ_22_KHZ,
  HAL_I2S_AUDIO_FREQ_16_KHZ,
  HAL_I2S_AUDIO_FREQ_11_KHZ,
  HAL_I2S_AUDIO_FREQ_8_KHZ,
  HAL_I2S_AUDIO_FREQ_DEFAULT
} hal_i2s_audio_frequency_t;

HAL I2S clock polarity constants

HAL1

HAL2



#define I2S_CPOL_LOW
#define I2S_CPOL_HIGH
typedef enum
{
  HAL_I2S_CLOCK_POLARITY_LOW,
  HAL_I2S_CLOCK_POLARITY_HIGH
} hal_i2s_clock_polarity_t;

HAL I2S data format constants

HAL1

HAL2



#define I2S_DATAFORMAT_16B
#define I2S_DATAFORMAT_16B_EXTENDED

#define I2S_DATAFORMAT_24B
#define I2S_DATA_24BIT_ALIGNMENT_RIGHT

#define I2S_DATA_24BIT_ALIGNMENT_LEFT

#define I2S_DATAFORMAT_32B
typedef enum
{
  HAL_I2S_DATA_FORMAT_16_BIT,
  HAL_I2S_DATA_FORMAT_16_BIT_EXTENDED,

  HAL_I2S_DATA_FORMAT_24_BIT,




  HAL_I2S_DATA_FORMAT_32_BIT
} hal_i2s_data_format_t;

HAL I2S first bit constants

HAL1

HAL2



#define I2S_FIRSTBIT_MSB
#define I2S_FIRSTBIT_LSB
typedef enum
{
  HAL_I2S_MSB_FIRST,
  HAL_I2S_LSB_FIRST
} hal_i2s_bit_order_t;

HAL I2S master mode constants

HAL1

HAL2



#define I2S_MODE_SLAVE_TX
#define I2S_MODE_SLAVE_RX
#define I2S_MODE_MASTER_TX
#define I2S_MODE_MASTER_RX
#define I2S_MODE_SLAVE_FULLDUPLEX
#define I2S_MODE_MASTER_FULLDUPLEX
typedef enum
{
  HAL_I2S_MODE_SLAVE_TX,
  HAL_I2S_MODE_SLAVE_RX,
  HAL_I2S_MODE_MASTER_TX,
  HAL_I2S_MODE_MASTER_RX,
  HAL_I2S_MODE_SLAVE_FULL_DUPLEX,
  HAL_I2S_MODE_MASTER_FULL_DUPLEX
} hal_i2s_mode_t;

HAL I2S standard protocol constants

HAL1

HAL2



#define I2S_STANDARD_PHILIPS
#define I2S_STANDARD_MSB
#define I2S_STANDARD_LSB
#define I2S_STANDARD_PCM_SHORT
#define I2S_STANDARD_PCM_LONG
typedef enum
{
  HAL_I2S_STANDARD_PHILIPS,
  HAL_I2S_STANDARD_MSB,
  HAL_I2S_STANDARD_LSB,
  HAL_I2S_STANDARD_PCM_SHORT,
  HAL_I2S_STANDARD_PCM_LONG
} hal_i2s_standard_t;

Related concepts:


Note

According to the concept Removal of hardware-related macros in HAL2 The defines and macros used to set, clear, enable, or disable interrupts and flags have been removed, instead, use the LL APIs. In the case of HAL I2S, the LL SPI interface is used to implement the I2S protocol.

HAL I2S status flags constants

The listed defines in HAL1 are used by : HAL I2S get flag, and HAL I2S clear flag.

HAL1

HAL2

#define I2S_FLAG_BSY
#define I2S_FLAG_CHSIDE

Removed; use LL_SPI_IsActiveFlag_BSY / LL_SPI_ClearFlag_BSY

#define I2S_FLAG_RXNE

Removed; use LL_SPI_IsActiveFlag_RXNE / LL_SPI_ClearFlag_RXNE

#define I2S_FLAG_TXE

Removed; use LL_SPI_IsActiveFlag_TXE / LL_SPI_ClearFlag_TXE

#define I2S_FLAG_DXP

Removed; use LL_SPI_IsActiveFlag_DXP instead

#define I2S_FLAG_FRE

Removed; use LL_I2S_IsActiveFlag_FRE / LL_I2S_ClearFlag_FRE instead.

#define I2S_FLAG_MASK

Removed; use LL_I2S_IsActiveFlag_RXP / LL_I2S_IsActiveFlag_TXP / LL_SPI_IsActiveFlag_DXP / LL_I2S_IsActiveFlag_UDR / LL_I2S_IsActiveFlag_OVR / LL_I2S_IsActiveFlag_FRE instead.

#define I2S_FLAG_OVR

Removed; use LL_I2S_IsActiveFlag_OVR / LL_I2S_ClearFlag_OVR instead.

#define I2S_FLAG_RXP

Removed; use LL_I2S_IsActiveFlag_RXP instead.

#define I2S_FLAG_TXP

Removed; use LL_I2S_IsActiveFlag_TXP instead.

#define I2S_FLAG_UDR

Removed; use LL_I2S_IsActiveFlag_UDR / LL_I2S_ClearFlag_UDR instead.


HAL I2S interrupt constants

The listed defines in HAL1 are used by : HAL I2S enable interrupt, HAL I2S disable interrupt, and HAL I2S get IT source.

HAL1

HAL2


#define I2S_IT_RXNE
#define I2S_IT_TXE
#define I2S_IT_DXP

#define I2S_IT_ERR



#define I2S_IT_FRE
#define I2S_IT_OVR
#define I2S_IT_RXP
#define I2S_IT_TXP
#define I2S_IT_UDR

All I2S interrupt definitions and macros are removed from HAL2.

/* To enable the specific IT use */ :
LL_SPI_EnableIT(SPI_TypeDef *p_spix, uint32_t mask)
/* To disable the specific IT use */ :
LL_SPI_DisableIT(SPI_TypeDef *p_spix, uint32_t mask)
/* To check if the specific IT is enabled use */ :
LL_SPI_IsEnabledIT(SPI_TypeDef *p_spix, uint32_t mask)

HAL I2S master keep IO state constants

HAL1

HAL2

In HAL1, the I2S master keep IO state is encapsulated as a member of the I2S_InitTypeDef structure.

Removed; In HAL2, the I2S master keep IO state is managed through dedicated unitary functions within the HAL layer.

For more details, refer to HAL I2S initialization type definition.

#define I2S_MASTER_KEEP_IO_STATE_DISABLE
#define I2S_MASTER_KEEP_IO_STATE_ENABLE
HAL_I2S_DisableMasterKeepIOState()
HAL_I2S_EnableMasterKeepIOState()

HAL I2S master clock output constants

HAL1

HAL2

In HAL1, the I2S master clock output is encapsulated as a member of the I2S_InitTypeDef structure.

Removed; In HAL2, the I2S master clock output is managed through dedicated unitary functions within the HAL layer.

For more details, refer to HAL I2S initialization type definition.

#define I2S_MCLKOUTPUT_DISABLE
#define I2S_MCLKOUTPUT_ENABLE
HAL_I2S_DisableMclkOutput()
HAL_I2S_EnableMclkOutput()

HAL I2S word select inversion constants

HAL1

HAL2

In HAL1, the I2S word select inversion is encapsulated as a member of the I2S_InitTypeDef structure.

Removed; In HAL2, the I2S word select inversion is managed by unitary functions in the HAL layer.

For more details, refer to HAL I2S initialization type definition.

#define I2S_WS_INVERSION_DISABLE
#define I2S_WS_INVERSION_ENABLE
HAL_I2S_DisableWSInversion()
HAL_I2S_EnableWSInversion()